package com.example.its2021606134chh.BusModule;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

/**
 * @ClassName: BusHistorySQLiteOpenHelper$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 20/8/2021$
 * @Version: 1.0
 */
public class BusHistorySQLiteOpenHelper extends SQLiteOpenHelper {
    public BusHistorySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table bushistory(id integer, busline_name varchar, start_place varchar, end_place varchar)";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }


//    static void dropDb(SQLiteDatabase db) {
//        Cursor cursor = db.rawQuery("SELECT name FROM sqlite_master WHERE type ='table' AND name != 'sqlite_sequence'", null);
//        if (cursor != null) {
//            while (cursor.moveToNext()) {
//                db.execSQL("DROP TABLE " + cursor.getString(0));
//            }
//        }
//        if (cursor != null) {
//            cursor.close();
//            cursor = null;
//        }
//    }
}
